// const hasPermission = {
//     install(Vue, options) {
//         Vue.directive('has', {
//             inserted: (el, binding, vnode) => {
//                 filterGlobalPermission(el, binding, vnode);
//             }
//         });
//         Vue.directive('disabled', {
//             bind: (el, binding, vnode) => {
//                 filterGlobalDisablePermission(el, binding, vnode)
//             }
//         });
//         Vue.directive('input', {
//             bind: (el, binding, vnode) => {
//                 filterGlobalInputPermission(el, binding, vnode)
//             }
//         });
//     }
// };
/**
 * 全局权限控制
 */
export const filterGlobalPermission = (el, binding) => {
  let buttons = localStorage.getItem('buttons') || []
  if (!buttons.includes(binding.value)) {
    el.parentNode.removeChild(el)
  }
}

export const filterGlobalDisablePermission = (el, binding) => {
  let buttons = localStorage.getItem('buttons') || []
  if (!buttons.includes(binding.value)) {
    el.disabled = true
  }
}

export const filterGlobalInputPermission = (el, binding) => {
  let buttons = localStorage.getItem('buttons') || []
  if (!buttons.includes(binding.value)) {
    el.lastChild.firstChild.disabled = true
    el.removeChild(el.firstChild)
  }
}
